﻿<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.STYLE1 {
	font-weight: bold
}
-->
</style>
<body class="no-skin">


	<!-- 以下为内容 -->
	<div class="main-content1">

		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
						try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
					</script>

			<ul class="breadcrumb" style="margin-top: 10px">
				<li><i class="ace-icon fa fa-home home-icon"></i> <a href="#">个人工作台</a>
				</li>
				<li class="active">密码修改</li>

			</ul>
			<!-- 路径结束 -->




		</div>

		<!-- /section:basics/content.breadcrumbs -->
		<div class="page-content">





			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<form id="pass_form" class="form-horizontal" role="form">
						<!-- #section:elements.form -->
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right"
								for="form-field-1"> 姓名 </label>

							<div class="col-sm-9">
								<input type="text" disabled="disabled"
									class="col-xs-10 col-sm-5" value="${user.userName}" />
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right"
								for="form-field-1-1" > 旧密码</label>

							<div class="col-sm-9">
							<div class="clearfix">
								<input type="password" id="old_pass" name="old_pass" placeholder="请输入原密码"
									class="col-xs-10 col-sm-5" />
									</div>
							</div>
						</div>

						<!-- /section:elements.form -->
						<div class="space-4"></div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right"
								for="form-field-2"> 新密码</label>

							<div class="col-sm-9">
							<div class="clearfix">
								<input type="password" id="new_pass" name="new_pass"  placeholder="请输入新密码"
									class="col-xs-10 col-sm-5" /> <span
									class="help-inline col-xs-12 col-sm-7"> </span>
								</div>
							</div>
						</div>

						





						<div class="space-4"></div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right"
								for="form-field-2"> 再次输入新密码</label>

							<div class="col-sm-9">
							<div class="clearfix">
								<input type="password" id="confirm_pass" name="confirm_pass" placeholder="请再次输入新密码"
									class="col-xs-10 col-sm-5" /> <span
									class="help-inline col-xs-12 col-sm-7"> </span>
									</div>
							</div>
						</div>
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button class="btn btn-info" type="button" id="btn_submit">
									<i class="ace-icon fa fa-check bigger-110"></i> 提 交
								</button>
								<button class="btn" type="reset">
									<i class="ace-icon fa fa-undo bigger-110"></i> 重 置
								</button>
							</div>
						</div>

					</form>

					<!-- PAGE CONTENT ENDS -->
				</div>
				<!-- /.col -->
			</div>

			<!-- /.row -->
		</div>
		<!-- /.page-content -->
	</div>
	<!-- /.main-content -->



	<a href="#" id="btn-scroll-up"
		class="btn-scroll-up btn btn-sm btn-inverse"> <i
		class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
	</a>
	</div>
	<!-- /.main-container -->

	<!-- basic scripts -->
	<script src="${resRoot}/plugin/ace-v1.3/assets/js/jquery.validate.min.js"></script>
	<script src="${resRoot}/plugin/jquery-validation/localization/messages_zh.js"></script>
	<script type="text/javascript" src="${resRoot }/js/jQuery.md5.js"></script>
	<script>
		$(function(){
			$("#btn_submit").click(function(){
				//$.Alert('fdasfa');
				$("#pass_form").submit();
			});
		});

		$(document).ready(function(){
			$('#pass_form').validate({
				errorElement: 'span',
				errorClass: 'help-block',
				focusInvalid: false,
				rules: {
					"old_pass": {
						required: true,
						remote:{
							url:contextPath+'/validPass.json',
						    data:{pwd:function(){return $.md5($("#old_pass").val())},loginId:"${user.loginId}"}
						}
					},
					"new_pass": {
						required: true
					},
					"confirm_pass": {
						required: true,
						equalTo:"#new_pass"
					}
				},
				
			 	messages: {
					"old_pass": {
						remote: "密码错误"
					},
					"confirm_pass": {
						equalTo:"两次输入密码不一致"
					}
				}, 
			
		
				highlight: function (e) {
					$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
				},
		
				success: function (e) {
					$(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
					$(e).remove();
				},
		
				errorPlacement: function (error, element) {
					if(element.is(':checkbox') || element.is(':radio')) {
						var controls = element.closest('div[class*="col-"]');
						if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
						else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
					}
					else if(element.is('.select2')) {
						error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
					}
					else if(element.is('.chosen-select')) {
						error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
					}
					else error.insertAfter(element.parent());
				},
		
				submitHandler: function (form) {
					changePass();
				},
				invalidHandler: function (form) {
					
				}
			});

		});
		

		function changePass(){
			$.ajax({
				url:contextPath+'/changePass.json',
				type:'post',
				data:'loginId=${user.loginId}'+'&pwd='+$.md5($("#new_pass").val()),
				success:function(data){
					$.Alert('密码修改成功');
				}
			});
		}
	</script>
</body>
</html>
